﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace AutoShutdownDotNet.Actions
{
    static class SystemActions
    {
       
        [DllImport("user32.dll")]
        public static extern void LockWorkStation();
        [DllImport("user32.dll")]
        public static extern int ExitWindowsEx(int uFlags, int dwReason);  

        public static void Logoff()
        {
            ExitWindowsEx(0, 0);
        }

        public static void Reboot()
        {
            ExitWindowsEx(2, 0);
        }

        public static void PowerOff()
        {
            ExitWindowsEx(1, 0);
        }

        public static void Hibernate()
        {
            Application.SetSuspendState(PowerState.Hibernate, true, true);
        }

        public static void Standby()
        {
            Application.SetSuspendState(PowerState.Suspend, true, true);
        }

        public static void Lock()
        {
            LockWorkStation();
        }

        public static void Run(string path)
        {
            Process.Start(path);
        }
    }
}
